#!/usr/bin/bash

while read value
do
  echo -n | openssl s_client -connect $value:443  > $value.pem
done < hosts.txt